---
title: "Bootstrapping"
author: "`r Sys.info()['user']`"
date: "`r format(Sys.time(), '%Y-%m-%d')`"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.width = 10, fig.height = 5)
dat_en <- readRDS("data_bootstrap_en.RDS")
dat_ja <- readRDS("data_bootstrap_ja.RDS")
```

```{r, fig.width = 10, fig.height = 5}
par(mfrow = c(1, 2), mar = c(4, 4, 4, 1), font.main = 1)
plot(dat_en$p, dat_en$r2, ylim = c(-0.2, 0.9), pch = 16, xlim = c(0, 100),
     ylab = "Correlation", xlab = "Size (%)", main = "Economy (English)", col = "gray")
grid()
dat_dummy <- data.frame(p = seq(5, 100, by = 5))
dat_dummy$r2 <- predict(lm(r2 ~ I(p ^ 2) + p, dat_en), newdata = dat_dummy)
lines(dat_dummy$p, dat_dummy$r2, lty = 2)

plot(dat_ja$p, dat_ja$r2, ylim = c(-0.2, 0.9), pch = 16, xlim = c(0, 100),
     ylab = "Correlation", xlab = "Size (%)", main = "Politics (Japanese)", col = "gray")
grid()
dat_dummy <- data.frame(p = seq(5, 100, by = 5))
dat_dummy$r2 <- predict(lm(r2 ~ I(p ^ 2) + p, dat_ja), newdata = dat_dummy)
lines(dat_dummy$p, dat_dummy$r2, lty = 2)
```
